//
//  ViewController.m
//  04-UI
//
//  Created by Snow on 16/7/19.
//  Copyright © 2016年 Snow. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//  background
    UIImageView *imageOfbackgroud = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"41_151008164557_5.jpg"]];
    imageOfbackgroud.frame = self.view.frame;
    [self.view addSubview:imageOfbackgroud];
    
    UIView *view = [[UIView alloc] initWithFrame:self.view.frame];
    view.backgroundColor = [UIColor blackColor];
    view.alpha = 0.8;
    [self.view addSubview:view];
    
//  center picture
    UIImageView *imageOfCenter = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"41_151008164557_5.jpg"]];
    imageOfCenter.frame = CGRectMake(75 / 2 , 130, 300, 300);
    imageOfCenter.layer.masksToBounds = YES;
    imageOfCenter.layer.cornerRadius = 150;
    [self.view addSubview:imageOfCenter];
    
    //SongName
    UILabel *labelOfSong = [[UILabel alloc] initWithFrame:CGRectMake(80, 20, 215, 30)];
    labelOfSong.text = @"12월24일-12月24日";
    labelOfSong.textAlignment = 1;
    labelOfSong.font = [UIFont systemFontOfSize:18];
    labelOfSong.textColor = [UIColor whiteColor];
    [view addSubview:labelOfSong];
    
    UIImageView *imageOfLeftButton = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Unknown"]];
    imageOfLeftButton.frame = CGRectMake(10, 25, 20, 20);
    [view addSubview:imageOfLeftButton];
    
    //labelOfSinger
    UILabel *labelOfSinger = [[UILabel alloc] initWithFrame:CGRectMake(150, 50, 75, 30)];
    labelOfSinger.text = @"아이유(IU)";
    labelOfSinger.textAlignment = 1;
    labelOfSinger.textColor = [UIColor whiteColor];
    [view addSubview:labelOfSinger];
    
    UIView *viewOfLeft = [[UIView alloc] initWithFrame:CGRectMake(130, 65, 20, 1)];
    UIView *viewOfRight = [[UIView alloc] initWithFrame:CGRectMake(225, 65, 20, 1)];
    viewOfLeft.backgroundColor = [UIColor whiteColor];
    viewOfRight.backgroundColor = [UIColor whiteColor];
    [view addSubview:viewOfLeft];
    [view addSubview:viewOfRight];
    
    //imageOfButton
    UIImageView *imageOfSong = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"player_btn_sq_sel_normal"]];
    imageOfSong.frame = CGRectMake(100, 85, 40, 20);
    [view addSubview:imageOfSong];
    
    UIImageView *imageOfMV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell_mv_icon"]];
    imageOfMV.frame = CGRectMake(160, 85, 40, 20);
    [view addSubview:imageOfMV];
    
    UIImageView *imageOfDTS = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"player_btn_dts_on_pressed"]];
    imageOfDTS.frame = CGRectMake(220, 85, 40, 20);
    [view addSubview:imageOfDTS];
    
    //labelOfLiric
    UILabel *labelOfLiric = [[UILabel alloc] initWithFrame:CGRectMake(130, 450, 115, 40)];
    labelOfLiric.text = @"12월24일-IU";
    labelOfLiric.textColor = [UIColor colorWithRed:0.18 green:0.8 blue:0.58 alpha:1];
    labelOfLiric.textAlignment = 1;
    [view addSubview:labelOfLiric];
    
    //UISlider
    UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(60, 480, 255, 30)];
    [view addSubview:slider];
    [slider setMinimumTrackImage:[UIImage imageNamed:@"player_slider_playback_left"] forState:UIControlStateNormal];
    [slider setMaximumTrackImage:[UIImage imageNamed:@"player_slider_playback_right"] forState:UIControlStateNormal];
    [slider setThumbImage:[UIImage imageNamed:@"player_slider_playback_thumb"] forState:UIControlStateNormal];
    slider.minimumValue = 0;
    slider.maximumValue = 1;
    slider.value = 0.3;
    //time
    UILabel *labelOfLeftTime = [[UILabel alloc] initWithFrame:CGRectMake(10, 480, 30, 40)];
    UILabel *labelOfRightTime = [[UILabel alloc] initWithFrame:CGRectMake(335, 480, 30, 40)];
    labelOfLeftTime.text = @"00:53";
    labelOfRightTime.text = @"03:53";
    labelOfLeftTime.textColor = [UIColor grayColor];
    labelOfRightTime.textColor = [UIColor grayColor];
    labelOfLeftTime.font = [UIFont systemFontOfSize:10];
    labelOfRightTime.font = [UIFont systemFontOfSize:10];
    [view addSubview:labelOfLeftTime];
    [view addSubview:labelOfRightTime];
   
    //player
    UIButton *buttonOfPlay = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonOfPlay.frame = CGRectMake(150, 510, 90, 90);
    [buttonOfPlay setBackgroundImage:[UIImage imageNamed:@"hp_player_btn_play_highlight"] forState:UIControlStateNormal];
    [view addSubview:buttonOfPlay];
    [buttonOfPlay addTarget:self action:@selector(handlePlay:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *buttonOfLeft = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonOfLeft.frame = CGRectMake(80, 520, 60, 60);
    [buttonOfLeft setBackgroundImage:[UIImage imageNamed:@"hp_player_btn_pre_highlight"] forState:UIControlStateNormal];
    [view addSubview:buttonOfLeft];
    
    UIButton *buttonOfRight = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonOfRight.frame = CGRectMake(250, 520, 60, 60);
    [buttonOfRight setBackgroundImage:[UIImage imageNamed:@"hp_player_btn_play_highlight"] forState:UIControlStateNormal];
    [view addSubview:buttonOfRight];
    
    //flag
    NSArray *array = @[@"assetimport_shoucang", @"miniplayer_btn_repeat_normal", @"actionIconDownloaded", @"actionIconShare", @"miniplayer_btn_playlist_disable"];
    for (NSInteger i = 0; i < 5; i++) {
        UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:array[i]]];
        image.frame = CGRectMake(5 + 375 / 5 * i, 600, 50, 50);
        [view addSubview:image];
    }
}

- (void)handlePlay:(UIButton *)button
{
    [button removeTarget:self action:@selector(handlePlay:) forControlEvents:UIControlEventTouchUpInside];
    [button addTarget:self action:@selector(handlePause:) forControlEvents:UIControlEventTouchUpInside];
    [button setBackgroundImage:[UIImage imageNamed:@"hp_player_btn_pause_highlight"] forState:UIControlStateNormal];
}
- (void)handlePause:(UIButton *)button
{
    [button removeTarget:self action:@selector(handlePause:) forControlEvents:UIControlEventTouchUpInside];
    [button addTarget:self action:@selector(handlePlay:) forControlEvents:UIControlEventTouchUpInside];
    [button setBackgroundImage:[UIImage imageNamed:@"hp_player_btn_play_highlight"] forState:UIControlStateNormal];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
